import request from '@/config/axios'
import { serviceApiMonitor } from '@/config/axios/service'
import signMd5Utils from '@/utils/signMd5Utils'
import axios from 'axios'
import { useAppStore } from '@/store/modules/app'
// import type { responseType } from './types'

const signHeader = (url: string, params: any) => {
  const sign = signMd5Utils.getSign(url, params)
  return { 'X-Sign': sign, 'X-TIMESTAMP': signMd5Utils.getDateTimeToString() }
}

// 获取时间
export const getSystemByToken = (params: any): Promise<LoginResponse> => {
  const sign = signMd5Utils.getSign('/sys/permission/getUserPermissionByToken', params)
  // //将签名和时间戳，添加在请求接口 Header
  const signHeader = { 'X-Sign': sign, 'X-TIMESTAMP': signMd5Utils.getDateTimeToString() }
  return request.get({
    url: '/sys/permission/getUserPermissionByToken',
    params,
    headers: signHeader
  })
}

export const getJvmMemoryMax = (params: any) => {
  return request.get({ url: '/actuator/metrics/jvm.memory.max', params })
}
export const getJvmMemoryCommitted = (params: any) => {
  return request.get({ url: '/actuator/metrics/jvm.memory.committed', params })
}
export const getJvmMemoryUsed = (params: any) => {
  return request.get({ url: '/actuator/metrics/jvm.memory.used', params })
}
export const getJvmBufferMemoryUsed = (params: any) => {
  return request.get({ url: '/actuator/metrics/jvm.buffer.memory.used', params })
}
export const getJvmBufferCount = (params: any) => {
  return request.get({ url: '/actuator/metrics/jvm.buffer.count', params })
}
export const getJvmThreadsDaemon = (params: any) => {
  return request.get({ url: '/actuator/metrics/jvm.threads.daemon', params })
}
export const getJvmThreadsLive = (params: any) => {
  return request.get({ url: '/actuator/metrics/jvm.threads.live', params })
}
export const getJvmThreadsPeak = (params: any) => {
  return request.get({ url: '/actuator/metrics/jvm.threads.peak', params })
}
export const getJvmClassesLoaded = (params: any) => {
  return request.get({ url: '/actuator/metrics/jvm.classes.loaded', params })
}
export const getJvmClassesUnloaded = (params: any) => {
  return request.get({ url: '/actuator/metrics/jvm.classes.unloaded', params })
}

export const getJvmGcMemoryAllocated = (params: any): Promise<MonitorResponse> => {
  return request.get({ url: '/actuator/metrics/jvm.gc.memory.allocated', params })
}
export const getJvmGcMemoryPromoted = (params: any): Promise<MonitorResponse> => {
  return request.get({ url: '/actuator/metrics/jvm.gc.memory.promoted', params })
}

export const getJvmGcMaxDataSize = (params: any): Promise<MonitorResponse> => {
  return request.get({ url: '/actuator/metrics/jvm.gc.max.data.size', params })
}
export const getJvmGcLiveDataSize = (params: any): Promise<MonitorResponse> => {
  return request.get({ url: '/actuator/metrics/jvm.gc.live.data.size', params })
}
export const getJvmGcPause = (params: any): Promise<MonitorResponse> => {
  return request.get({ url: '/actuator/metrics/jvm.gc.pause', params })
}
/*
export const getJvmMemoryMax = (params: any): Promise<MonitorResponse> => {
  return serviceApiMonitor({
    method: 'get',
    url: '/actuator/metrics/jvm.memory.max',
    params,
    headers: signHeader('/actuator/metrics/jvm.memory.max', params)
  })
}

export const getJvmMemoryCommitted = (params: any): Promise<MonitorResponse> => {
  return serviceApiMonitor({
    method: 'get',
    url: '/actuator/metrics/jvm.memory.committed',
    params,
    headers: signHeader('/actuator/metrics/jvm.memory.committed', params)
  })
}
export const getJvmMemoryUsed = (params: any): Promise<MonitorResponse> => {
  return serviceApiMonitor({
    method: 'get',
    url: '/actuator/metrics/jvm.memory.used',
    params,
    headers: signHeader('/actuator/metrics/jvm.memory.used', params)
  })
}
export const getJvmBufferMemoryUsed = (params: any): Promise<MonitorResponse> => {
  return serviceApiMonitor({
    method: 'get',
    url: '/actuator/metrics/jvm.buffer.memory.used',
    params,
    headers: signHeader('/actuator/metrics/jvm.buffer.memory.used', params)
  })
}
export const getJvmBufferCount = (params: any): Promise<MonitorResponse> => {
  return serviceApiMonitor({
    method: 'get',
    url: '/actuator/metrics/jvm.buffer.count',
    params,
    headers: signHeader('/actuator/metrics/jvm.buffer.count', params)
  })
}
export const getJvmThreadsDaemon = (params: any): Promise<MonitorResponse> => {
  return serviceApiMonitor({
    method: 'get',
    url: '/actuator/metrics/jvm.threads.daemon',
    params,
    headers: signHeader('/actuator/metrics/jvm.threads.daemon', params)
  })
}
export const getJvmThreadsLive = (params: any): Promise<MonitorResponse> => {
  return serviceApiMonitor({
    method: 'get',
    url: '/actuator/metrics/jvm.threads.live',
    params,
    headers: signHeader('/actuator/metrics/jvm.threads.live', params)
  })
}
export const getJvmThreadsPeak = (params: any): Promise<MonitorResponse> => {
  return serviceApiMonitor({
    method: 'get',
    url: '/actuator/metrics/jvm.threads.peak',
    params,
    headers: signHeader('/actuator/metrics/jvm.threads.peak', params)
  })
}
export const getJvmClassesLoaded = (params: any): Promise<MonitorResponse> => {
  return serviceApiMonitor({
    method: 'get',
    url: '/actuator/metrics/jvm.classes.loaded',
    params,
    headers: signHeader('/actuator/metrics/jvm.classes.loaded', params)
  })
}
export const getJvmClassesUnloaded = (params: any): Promise<MonitorResponse> => {
  return serviceApiMonitor({
    method: 'get',
    url: '/actuator/metrics/jvm.classes.unloaded',
    params,
    headers: signHeader('/actuator/metrics/jvm.classes.unloaded', params)
  })
}
export const getJvmGcMemoryAllocated = (params: any): Promise<MonitorResponse> => {
  return serviceApiMonitor({
    method: 'get',
    url: '/actuator/metrics/jvm.gc.memory.allocated',
    params,
    headers: signHeader('/actuator/metrics/jvm.gc.memory.allocated', params)
  })
}
export const getJvmGcMemoryPromoted = (params: any): Promise<MonitorResponse> => {
  return serviceApiMonitor({
    method: 'get',
    url: '/actuator/metrics/jvm.gc.memory.promoted',
    params,
    headers: signHeader('/actuator/metrics/jvm.gc.memory.promoted', params)
  })
}

export const getJvmGcMaxDataSize = (params: any): Promise<MonitorResponse> => {
  return serviceApiMonitor({
    method: 'get',
    url: '/actuator/metrics/jvm.gc.max.data.size',
    params,
    headers: signHeader('/actuator/metrics/jvm.gc.max.data.size', params)
  })
}
export const getJvmGcLiveDataSize = (params: any): Promise<MonitorResponse> => {
  return serviceApiMonitor({
    method: 'get',
    url: '/actuator/metrics/jvm.gc.live.data.size',
    params,
    headers: signHeader('/actuator/metrics/jvm.gc.live.data.size', params)
  })
}
export const getJvmGcPause = (data: any): Promise<MonitorResponse> => {
  return serviceApiMonitor({
    method: 'get',
    url: '/actuator/metrics/jvm.gc.pause',
    data,
    headers: signHeader('/actuator/metrics/jvm.gc.pause', data)
  })
}
*/
